package dk.itu.iwjx.helper;

public class Factory {
	private static  Factory instance = new Factory();
    
    private UserHelper userHelper = null;
    private PizzaHelper pizzaHelper = null;
    // private constructor, we don't want the class to be instantiated from
    // others.
    private Factory() {
	//does nothing
    }
 
    public static Factory instance() {
	     return instance;
    }
 
    /**
     * returns the  object contained in the singleton, the object is created lazily
     *  
     * @return   the "singletonized" class
     */
    public UserHelper getUserHelper() {
	if (this.userHelper == null){
                    synchronized ( this ) {
                       if ( this.userHelper == null ) {
	          this.userHelper = new UserHelper();
                       }
                    }
	}
	return this.userHelper;
    }
    
    /*
     * PizzaHelper 
     */
    public PizzaHelper getPizzaHelper() {
    	if (this.pizzaHelper == null){
                        synchronized ( this ) {
                           if ( this.pizzaHelper == null ) {
    	          this.pizzaHelper = new PizzaHelper();
                           }
                        }
    	}
    	return this.pizzaHelper;
        }

}
